<template>
  <view class="mine-container" :style="{paddingTop: `${statusBarHeight}px`}">
    <!--顶部个人信息栏-->
    <view class="header-section">
      <view class="flex padding justify-between">
        <view class="flex align-center">
          <view v-if="!avatar" class="cu-avatar xl round bg-white">
            <view class="iconfont icon-people text-gray icon"></view>
          </view>
          <image v-if="avatar" @click="handleToAvatar" :src="avatar" class="cu-avatar xl round" mode="widthFix">
          </image>
          <view v-if="!name" @click="handleToLogin" class="login-tip">
            点击登录
          </view>
          <view v-if="name" class="user-info">
            <view class="u_title">
              用户名：{{ name }}
            </view>
          </view>
        </view>
       <!-- <view @click="handleToInfo" class="flex align-center">
          <text>个人信息</text>
          <view class="iconfont icon-right"></view>
        </view> -->
      </view>
    </view>

    <!-- <view class="content-section">
      <view class="mine-actions grid col-4 text-center">
        <view class="action-item" @click="handleJiaoLiuQun">
          <view class="iconfont icon-friendfill text-pink icon"></view>
          <text class="text">交流群</text>
        </view>
        <view class="action-item" @click="handleBuilding">
          <view class="iconfont icon-service text-blue icon"></view>
          <text class="text">在线客服</text>
        </view>
        <view class="action-item" @click="handleBuilding">
          <view class="iconfont icon-community text-mauve icon"></view>
          <text class="text">反馈社区</text>
        </view>
        <view class="action-item" @click="handleBuilding">
          <view class="iconfont icon-dianzan text-green icon"></view>
          <text class="text">点赞我们</text>
        </view>
      </view> -->

    <view class="content-section">
      <view class="menu-list">
       <!-- <view class="list-cell list-cell-arrow" @click="handleToJobPreference">
          <view class="menu-item-box job-preference">
            <uni-icons type="star" size="22" color="#ffa502" class="menu-icon"></uni-icons>
            <view>岗位优选</view>
          </view>
        </view> -->
        <view class="list-cell list-cell-arrow" @click="handleToFavoriteJobs">
          <view class="menu-item-box favorite-jobs">
            <uni-icons type="heart-filled" size="22" color="#ff4757" class="menu-icon"></uni-icons>
            <view>意向岗位</view>
          </view>
        </view>
        <view class="list-cell list-cell-arrow" @click="handleToNotices">
          <view class="menu-item-box notice-favorite">
            <uni-icons type="notification-filled" size="22" color="#3498db" class="menu-icon"></uni-icons>
            <view>关注公告</view>
          </view>
        </view>
        <view class="list-cell list-cell-arrow" @click="handleToEditInfo">
          <view class="menu-item-box edit-info">
            <uni-icons type="compose" size="22" color="#2ecc71" class="menu-icon"></uni-icons>
            <view>编辑资料</view>
          </view>
        </view>
        <view class="list-cell list-cell-arrow" @click="handleHelp">
          <view class="menu-item-box help">
            <uni-icons type="help-filled" size="22" color="#9b59b6" class="menu-icon"></uni-icons>
            <view>常见问题</view>
          </view>
        </view>
        <view class="list-cell list-cell-arrow" @click="handleAbout">
          <view class="menu-item-box about-us">
            <uni-icons type="info-filled" size="22" color="#1abc9c" class="menu-icon"></uni-icons>
            <view>关于我们</view>
          </view>
        </view>
        <view class="list-cell list-cell-arrow" @click="handleToSetting">
          <view class="menu-item-box settings">
            <uni-icons type="gear" size="22" color="#7f8c8d" class="menu-icon"></uni-icons>
            <view>应用设置</view>
          </view>
        </view>
      </view>
    </view>

    <!-- 匹配动画组件，初始不显示 -->
    <match-animation v-if="showMatchAnimation" :visible="true" />
  </view>
</template>

<script>
import { logout } from '@/api/login'
import storage from '@/utils/storage'
import MatchAnimation from '@/components/match-animation/match-animation.vue'
import uniIcons from '@/uni_modules/uni-icons/components/uni-icons/uni-icons.vue'

export default {
  name: 'Mine',
  components: {
    MatchAnimation,
    uniIcons
  },
  data() {
    return {
      name: this.$store.state.user.nickName,
      version: getApp().globalData.config.appInfo.version,
      statusBarHeight: 0,
      showMatchAnimation: false
    }
  },
  computed: {
    avatar() {
      return this.$store.state.user.avatar
    },
    windowHeight() {
      return uni.getSystemInfoSync().windowHeight - 50
    }
  },
  onLoad() {
    console.log("666"+this.avatar)
    // 获取状态栏高度
    const systemInfo = uni.getSystemInfoSync();
    this.statusBarHeight = systemInfo.statusBarHeight;
  },
  methods: {
    handleToInfo() {
      this.$tab.navigateTo('/pagesA/mine/info/index')
    },
    handleToEditInfo() {
      this.$tab.navigateTo('/pagesA/mine/info/edit')
    },
    handleToSetting() {
      this.$tab.navigateTo('/pagesA/mine/setting/index')
    },
    handleToLogin() {
      this.$tab.reLaunch('/pages/login')
    },
    handleToAvatar() {
      this.$tab.navigateTo('/pagesA/mine/avatar/index')
    },
    handleLogout() {
      this.$modal.confirm('确定注销并退出系统吗？').then(() => {
        this.$store.dispatch('LogOut').then(() => {
          this.$tab.reLaunch('/pages/index')
        })
      })
    },
    handleHelp() {
      this.$tab.navigateTo('/pagesA/mine/help/index')
    },
    handleAbout() {
      this.$tab.navigateTo('/pagesA/mine/about/index')
    },
    handleJiaoLiuQun() {
      this.$modal.showToast('QQ群：①133713780、②146013835')
    },
    handleBuilding() {
      this.$modal.showToast('模块建设中~')
    },
    handleToJobPreference() {
      // 显示动画
      this.showMatchAnimation = true
      
      // 3秒后跳转并隐藏动画
      setTimeout(() => {
        // 先隐藏动画
        this.showMatchAnimation = false
        // 等待动画消失后再跳转
        setTimeout(() => {
          this.$tab.navigateTo('/pagesA/mine/suggest/index')
        }, 300)
      }, 3000)
    },
    handleToFavoriteJobs() {
      // 跳转到意向岗位页面
      this.$tab.navigateTo('/pagesA/mine/likeJob/index')
    },
    handleToNotices() {
      // 跳转到关注公告页面
      this.$tab.navigateTo('/pagesA/mine/likeNotice/index')
    }
  }
}
</script>

<style lang="scss">
  page {
    background-color: #f5f6f7;
  }

  .mine-container {
    width: 100%;
    min-height: 100vh;
    background-color: #f5f6f7;

    .header-section {
      padding: 15px 15px 45px 15px;
      background-color: #3c96f3;
      color: white;
      margin-top: 0; // 移除负边距
      padding-top: 20px; // 增加顶部内边距，确保在状态栏下方

      .login-tip {
        font-size: 18px;
        margin-left: 10px;
      }

      .cu-avatar {
        border: 2px solid #eaeaea;

        .icon {
          font-size: 40px;
        }
      }

      .user-info {
        margin-left: 15px;

        .u_title {
          font-size: 18px;
          line-height: 30px;
        }
      }
    }

    .content-section {
      position: relative;
      margin-top: -30px;
      padding-top: 5px;
      background-color: #f5f6f7;
    }
  }

  .menu-list {
    margin: 15px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05); // 添加轻微阴影
    
    .list-cell {
      padding: 15px;
      border-bottom: 1px solid #f5f5f5;
      
      &:last-child {
        border-bottom: none;
      }
      
      .menu-item-box {
        display: flex;
        align-items: center;
        
        .menu-icon {
          font-size: 22px;
          margin-right: 10px;
          color: #ff7043;
          display: flex;
          align-items: center;
        }
      }
      
      /* Custom colors for each menu item icon */
      .menu-item-box.favorite-jobs .menu-icon {
        color: #ff4757; /* Red color for favorite/like icon */
      }
      
      .menu-item-box.job-preference .menu-icon {
        color: #ffa502; /* Orange color for job preference */
      }
      
      .menu-item-box.notice-favorite .menu-icon {
        color: #3498db; /* Blue color for notice favorite */
      }
      
      .menu-item-box.edit-info .menu-icon {
        color: #2ecc71; /* Green color for edit info */
      }
      
      .menu-item-box.help .menu-icon {
        color: #9b59b6; /* Purple color for help */
      }
      
      .menu-item-box.about-us .menu-icon {
        color: #1abc9c; /* Teal color for about us */
      }
      
      .menu-item-box.settings .menu-icon {
        color: #7f8c8d; /* Gray color for settings */
      }
    }
  }
</style>
